home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Tools - Objects / MacApp / MacApp 2.0.1 / MacApp CD Release / MacApp 2.0.1 (Hard Disk Ready) / Libraries / UMacApp.TCommand.p < prev    next >
Text File  |  1990-10-25  |  6KB  |  215 lines

  1. {$P}
  2. {[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n-]}
  3. { UMacApp.TCommand.p }
  4. { Copyright © 1985-1990 by Apple Computer, Inc.  All rights reserved. }
  5.  
  6. {--------------------------------------------------------------------------------------------------}
  7. {$S MACommandRes}
  8.  
  9. PROCEDURE TCommand.ICommand(itsCmdNumber: CmdNumber;
  10.                             itsDocument: TDocument;
  11.                             itsView: TView;
  12.                             itsScroller: TScroller);
  13.  
  14.     BEGIN
  15.     IObject;
  16.  
  17.     fCmdNumber := itsCmdNumber;
  18.     fChangedDocument := itsDocument;
  19.     fCmdDone := FALSE;
  20.     fCanUndo := TRUE;
  21.     fCausesChange := TRUE;
  22.     fChangesClipboard := FALSE;
  23.     fFreeOnCompletion := TRUE;                            { command will be freed after DoIt or Commit
  24.                                                          }
  25.     fRecurring := FALSE;                                { Command is a one-shot deal }
  26.     fPriority := kPriorityNormal;                        { Don't worry, be happy! }
  27.     fReadyToExecute := TRUE;                            { Always executable by default }
  28.  
  29.     fTracksMouse := FALSE;                                { Set to true by
  30.                                                          TApplication.HandleMouseDown for
  31.                                                          compatibility (2.0) }
  32.     fInitialPt := gZeroPt;                                { Best initial value }
  33.     fConstrainsMouse := FALSE;
  34.     fViewConstrain := TRUE;
  35.     fTrackNonMovement := FALSE;
  36.     fView := itsView;
  37.     fScroller := itsScroller;
  38.     END;
  39.  
  40. {--------------------------------------------------------------------------------------------------}
  41. {$S MADoCommand}
  42.  
  43. PROCEDURE TCommand.AutoScroll(deltaH, deltaV: VCoordinate);
  44.  
  45.     BEGIN
  46.     IF fScroller <> NIL THEN
  47.         fScroller.ScrollBy(deltaH, deltaV, kRedraw)
  48.     ELSE
  49.         BEGIN
  50.         {??? any sensible behaviour here? }
  51.         END;
  52.     END;
  53.  
  54. {--------------------------------------------------------------------------------------------------}
  55. {$S MADoCommand}
  56.  
  57. PROCEDURE TCommand.Commit;
  58.  
  59.     BEGIN
  60.     END;
  61.  
  62. {--------------------------------------------------------------------------------------------------}
  63. {$S MADoCommand}
  64.  
  65. PROCEDURE TCommand.DoIt;
  66.  
  67.     BEGIN
  68.     END;
  69.  
  70. {--------------------------------------------------------------------------------------------------}
  71. {$S MADoCommand}
  72.  
  73. FUNCTION TCommand.IsDoneTracking: BOOLEAN;
  74.  
  75.     BEGIN
  76.     IF fView <> NIL THEN
  77.         IsDoneTracking := fView.IsDoneTracking
  78.     ELSE
  79.     {??? Would it be better to let the application have a crack at it here?}
  80.         IsDoneTracking := NOT StillDown;
  81.     END;
  82.  
  83. {--------------------------------------------------------------------------------------------------}
  84. {$S MACommandRes}
  85.  
  86. FUNCTION TCommand.IsReadyToExecute: BOOLEAN;
  87.  
  88.     BEGIN
  89.     IsReadyToExecute := fReadyToExecute;
  90.     END;
  91.  
  92. {--------------------------------------------------------------------------------------------------}
  93. {$S MADoCommand}
  94.  
  95. PROCEDURE TCommand.RedoIt;
  96.  
  97.     BEGIN
  98.     END;
  99.  
  100. {--------------------------------------------------------------------------------------------------}
  101. {$S MADoCommand}
  102.  
  103. PROCEDURE TCommand.TrackConstrain(anchorPoint, previousPoint: VPoint;
  104.                                   VAR nextPoint: VPoint);
  105.  
  106.     BEGIN
  107.     IF fView <> NIL THEN
  108.         fView.TrackConstrain(anchorPoint, previousPoint, nextPoint)
  109.     ELSE
  110.         BEGIN
  111.         {??? should this call back into an application method if there is no view? }
  112.         END;
  113.     END;
  114.  
  115. {--------------------------------------------------------------------------------------------------}
  116. {$S MADoCommand}
  117.  
  118. PROCEDURE TCommand.TrackFeedback(anchorPoint, nextPoint: VPoint;
  119.                                  turnItOn, mouseDidMove: BOOLEAN);
  120.  
  121.     BEGIN
  122.     IF fView <> NIL THEN
  123.         fView.TrackFeedback(anchorPoint, nextPoint, turnItOn, mouseDidMove)
  124.     ELSE
  125.         BEGIN
  126.         {??? should this call back into an application method if there is no view? }
  127.         END;
  128.     END;
  129.  
  130. {--------------------------------------------------------------------------------------------------}
  131. {$S MADoCommand}
  132.  
  133. FUNCTION TCommand.TrackMouse(aTrackPhase: TrackPhase;
  134.                              VAR anchorPoint, previousPoint, nextPoint: VPoint;
  135.                              mouseDidMove: BOOLEAN): TCommand;
  136.  
  137.     BEGIN
  138.     IF fView <> NIL THEN
  139.         fView.TrackMouse(aTrackPhase, anchorPoint, previousPoint, nextPoint, mouseDidMove)
  140.     ELSE
  141.         BEGIN
  142.         {??? should this call back into an application method if there is no view? }
  143.         END;
  144.  
  145.     IF (aTrackPhase = trackRelease) & ((fView = NIL) | (NOT fView.ContainsMouse(nextPoint))) THEN
  146.         TrackMouse := NIL
  147.     ELSE
  148.         TrackMouse := SELF;
  149.     END;
  150.  
  151. {--------------------------------------------------------------------------------------------------}
  152. {$S MADoCommand}
  153.  
  154. PROCEDURE TCommand.UndoIt;
  155.  
  156.     BEGIN
  157.     END;
  158.  
  159. {--------------------------------------------------------------------------------------------------}
  160. {$S MAFields}
  161.  
  162. PROCEDURE TCommand.Fields(PROCEDURE DoToField(fieldName: Str255;
  163.                                               fieldAddr: Ptr;
  164.                                               fieldType: INTEGER)); OVERRIDE;
  165.  
  166.     BEGIN
  167.     DoToField('TCommand', NIL, bClass);
  168.     DoToField('fCanUndo', @fCanUndo, bBoolean);
  169.     DoToField('fCausesChange', @fCausesChange, bBoolean);
  170.     DoToField('fChangedDocument', @fChangedDocument, bObject);
  171.     DoToField('fChangesClipboard', @fChangesClipboard, bBoolean);
  172.     DoToField('fCmdDone', @fCmdDone, bBoolean);
  173.     DoToField('fCmdNumber', @fCmdNumber, bCmdNumber);
  174.     DoToField('fConstrainsMouse', @fConstrainsMouse, bBoolean);
  175.     DoToField('fFreeOnCompletion', @fFreeOnCompletion, bBoolean);
  176.     DoToField('fInitialPt', @fInitialPt, bPoint);
  177.     DoToField('fPriority', @fPriority, bByte);
  178.     DoToField('fReadyToExecute', @fReadyToExecute, bBoolean);
  179.     DoToField('fRecurring', @fRecurring, bBoolean);
  180.     DoToField('fScroller', @fScroller, bObject);
  181.     DoToField('fTrackNonMovement', @fTrackNonMovement, bBoolean);
  182.     DoToField('fTracksMouse', @fTracksMouse, bBoolean);
  183.     DoToField('fView', @fView, bObject);
  184.     DoToField('fViewConstrain', @fViewConstrain, bBoolean);
  185.     INHERITED Fields(DoToField);
  186.     END;
  187.  
  188. {--------------------------------------------------------------------------------------------------}
  189. {$S MACommandRes}
  190.  
  191. PROCEDURE TNoChangesCommand.INoChangesCommand(itsCmdNumber: CmdNumber;
  192.                                               itsDocument: TDocument;
  193.                                               itsView: TView;
  194.                                               itsScroller: TScroller);
  195.  
  196.     BEGIN
  197.     ICommand(itsCmdNumber, itsDocument, itsView, itsScroller);
  198.  
  199.     { we said NO changes }
  200.     fCanUndo := FALSE;
  201.     fCausesChange := FALSE;
  202.     END;
  203.  
  204. {--------------------------------------------------------------------------------------------------}
  205. {$S MAFields}
  206.  
  207. PROCEDURE TNoChangesCommand.Fields(PROCEDURE DoToField(fieldName: Str255;
  208.                                                        fieldAddr: Ptr;
  209.                                                        fieldType: INTEGER)); OVERRIDE;
  210.  
  211.     BEGIN
  212.     DoToField('TNoChangesCommand', NIL, bClass);
  213.     INHERITED Fields(DoToField);
  214.     END;
  215.